package jnpf.engine.custom.xml.impl;


import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.converter.ManualTaskXMLConverter;
import org.flowable.bpmn.converter.ReceiveTaskXMLConverter;
import org.flowable.bpmn.converter.util.BpmnXMLUtil;
import org.flowable.bpmn.model.BaseElement;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.ManualTask;

import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;

@Slf4j
public class CustomManualTaskXMLConverter extends ManualTaskXMLConverter {
    @Override
    protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
        ManualTask manualTask = new ManualTask();
        BpmnXMLUtil.addXMLLocation(manualTask, xtr);
        BpmnXMLUtil.addCustomAttributes(xtr, manualTask, defaultElementAttributes,defaultActivityAttributes);
        parseChildElements(getXMLElementName(), manualTask, model, xtr);
        return manualTask;
    }

    @Override
    protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
        ManualTask manualTask = (ManualTask) element;
        BpmnXMLUtil.writeCustomAttributes(manualTask.getAttributes().values(), xtw, defaultElementAttributes,
                defaultActivityAttributes);
    }
}
